﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";

    var user = "{\"id\": null, \"UserName\": null, \"Password\": null, \"Email\": null}";
    try{
        user = FormsAuthentication.Decrypt(this.Context.Request.Cookies[FormsAuthentication.FormsCookieName].Value).UserData;
    } catch {}
}

<a class="sr-only" href="#content">Skip navigation</a>
<!-- master nav -->
<header class="navbar navbar-inverse navbar-fixed-top bs-docs-nav" role="banner">
    <div class="container">
        <div class="navbar-header">
            <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a href="/Knowledge" class="navbar-brand">
                Mysoft 明源
            </a>
        </div>
        <nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
            <ul class="nav navbar-nav">
                <li class="active">
                    <a href="/Knowledge">
                        <i class="icon-stackexchange"></i>
                        Knowledge Lib
                        <i class="tip-sup">Beta*</i>
                    </a>
                </li>
            </ul>
            <ul id="loginContainer" class="nav navbar-nav navbar-right">
                <li>
                    <a href="/User/AuthLogin">
                        <i class="icon-user"></i>
                        登陆
                    </a>
                </li>
                <li class="dropdown hidden">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <i class="icon-user"></i>
                        <b class="caret"></b>
                    </a>
                    <ul class="dropdown-menu">
                        <li><a href="/Knowledge/User">收藏</a></li>
                        <li class="hidden"><a href="#loginout" onclick="userJson.event.loginout();">注销</a></li>
                    </ul>
                </li>
            </ul>
        </nav>
    </div>
</header>
@RenderBody()
<!-- Footer -->
<footer class="bs-footer hidden" role="contentinfo">
    <div class="container">
        
    </div>
</footer>

@section Styles {
    @Stylesheet.Render("bootstrap.theme.doc")
    @Stylesheet.Render("/assets/css/style.css")
    @RenderSection("Styles", false)
}

@section Scripts{
    <script type="text/javascript">
        var userJson = $.parseJSON(("@user").replace(/&quot;/g, '"'));
        userJson.event = {};
        userJson.event.loginin = function () {
            if (userJson.id != null) {
                $('#loginContainer > li').toggleClass('hidden');
                $('#loginContainer').find('.dropdown .icon-user').after('&nbsp;' + userJson.UserName);
            }
        };
        userJson.event.loginout = function () {
            $.ajax({
                url: '/User/LoginOut'
            }).then(function () {
                alert($('#loginContainer > li').size())
                $('#loginContainer > li').toggleClass('hidden');
            });
        };
        $(userJson.event.loginin);
    </script>
    @RenderSection("Scripts", required: false)
}